// 放置全局指令
import Vue from 'vue'
import store from '@/store'
//页面按钮权限校验
const adminPermissions = '*:*:*'
Vue.directive('permission', {
  inserted (el, binding) {
    // console.log(store.state.user.permissions)
    const permissions = store.state.user.permissions
    if (permissions.includes(adminPermissions)) return // 管理员权限
    if (!permissions.includes(binding.value)) {
      el.remove() // 知识点：移除元素，而不是设置display，避免用户修改页面样式把按钮展示出来
    }
  }
})
